unit MLPAGetProbeInfo;

interface

uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls, 
  Buttons, ExtCtrls;

type
  TdlgGetProbeInfo = class(TForm)
    OKBtn: TButton;
    CancelBtn: TButton;
    Bevel1: TBevel;
    lbProbeInfo: TListBox;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
  private
    { Private declarations }
  public
    { Public declarations }
    function DoDialog(kitid:string;out ControlProbes,ExcludedProbes:string):boolean;
  end;

var
  dlgGetProbeInfo: TdlgGetProbeInfo;

implementation

uses MLPAdm;

{$R *.DFM}

{ TdlgGetProbeInfo }

function TdlgGetProbeInfo.DoDialog(kitid: string; out ControlProbes,
  ExcludedProbes: string): boolean;
var
  slControlProbes:TStringlist;
  slExcludedProbes:TStringlist;
  currItem:Integer;

  function ElementCount(probes:string):string;
  var
    i:integer;
    n:integer;
  begin
    n:=0;
    if Length(probes)>0 then
    begin
      n:=1;
      for i:=1 to length(probes) do
        if probes[i]=',' then
          Inc(n);
    end;
    result:='  '+IntToStr(n);
    result:=copy(result,length(result)-2,3);
  end;

begin
  // find all analyses with kitid
  // fill
  slControlprobes:=TStringList.Create;
  slExcludedProbes:=TStringList.Create;
  lbProbeInfo.Items.Clear;
  try
    result:=false;
    DM.qryCustom.Active:=false;
    Dm.qryCustom.SQL.Text:='SELECT controlprobes, excludedprobes FROM tbl_Analyses WHERE (kitid = '+QuotedStr(kitid)+' )';
    DM.qryCustom.Active:=true;
    while not DM.qryCustom.Eof do
    begin
      slControlProbes.Add(DM.qryCustom.FieldByName('controlprobes').AsString);
      currItem:=slExcludedProbes.Add(DM.qryCustom.FieldByName('excludedprobes').AsString);
      lbProbeInfo.Items.Add('  '+ElementCount(slControlProbes[currItem])+'     '+ElementCount(slExcludedProbes[currItem]));
      dm.qryCustom.Next;
    end;
    result:=false;
    if ShowModal=mrOK then
    begin
      if lbProbeInfo.ItemIndex>=0 then
      begin
        ControlProbes:=slControlProbes[lbProbeInfo.ItemIndex];
        ExcludedProbes:=slExcludedProbes[lbProbeInfo.ItemIndex];
        result:=true;
      end;
    end;
  finally
    slControlProbes.Free;
    slExcludedProbes.Free;
  end;

end;

end.
